package com.cby.ssm.service.impl;

import com.cby.ssm.dao.User_RoleDao;
import com.cby.ssm.entity.User_RoleEntity;
import com.cby.ssm.service.User_RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 13296 on 2017/7/24.
 */
@Service
public class User_RoleServiceImpl implements User_RoleService {
    @Autowired
    User_RoleDao urdao;
    @Override
    public List<User_RoleEntity> SearchAllRolesByUserId(String userId) throws Exception {
        List<User_RoleEntity> list = urdao.selectAllRoleByUserId(userId);
        return list;
    }

    @Override
    public List<User_RoleEntity> SearchAllUsersByRoleId(String roleId) throws Exception {
        List<User_RoleEntity> list = urdao.selectAllUserByRoleId(roleId);
        return list;
    }

    @Override
    public boolean deleteRolesOfUserId(String userId) throws Exception {
        urdao.delete("userId",userId);
        return false;
    }

    @Override
    public void addRoleOfUserId(String userId,String roleId) throws Exception {
        User_RoleEntity ur = new User_RoleEntity(userId,roleId);
        urdao.insert(ur);
    }
}
